package com.ruoyi.dataroom.controller;

import com.ruoyi.dataroom.constant.DataRoomConst;
import com.ruoyi.dataroom.module.basic.entity.PageEntity;
import com.ruoyi.dataroom.module.manage.dto.DataRoomSearchDTO;
import com.ruoyi.dataroom.module.manage.service.IDataRoomPageService;
import com.ruoyi.dataroom.permission.Permission;
import com.ruoyi.common.permission.ApiPermission;
import com.ruoyi.common.vo.MixinsResp;
import com.ruoyi.common.vo.PageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/bigScreen/design")
@Tag(name = "大屏页以及大屏组件设计")
public class DataRoomPageController {

    @Resource
    private IDataRoomPageService bigScreenPageService;

    @ApiPermission(permissions = {Permission.DataRoom.VIEW})
    @GetMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "大屏/组件分页列表")
    public MixinsResp<PageVO<PageEntity>> page(DataRoomSearchDTO searchDTO) {
        PageVO<PageEntity> page = bigScreenPageService.getByCategory(searchDTO);
        MixinsResp<PageVO<PageEntity>> resp = new MixinsResp<PageVO<PageEntity>>().setData(page);
        resp.setCode(DataRoomConst.Response.Code.SUCCESS);
        return resp;
    }
}
